<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateMerchantsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('merchants', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('user_id')->comment('用户id')->index();
            $table->unsignedInteger('client_id')->comment('商户应用id')->unique();
            $table->string('name')->nullable()->comment('名称');
            $table->string('client_secret', 32)->comment('唯一key');
            $table->decimal('balance')->default(0)->comment('余额');
            $table->decimal('frozen_balance')->default(0)->comment('冻结余额');
            $table->string('notify_type')->default(\App\Models\Merchant::NOTIFY_TYPE_NORMAL)->comment('异步通知类型');
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('merchants');
    }
}
